using System;
using FU.Capstones.IMS.Web.Common;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.DataContracts;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.EventArgs;

namespace FU.Capstones.IMS.Web.Silverlight.Models
{
    public class MatarialOrderListModel : ModelBase
    {
        public MatarialOrderListModel()
        {
            
            client.GetOrderCollectionByParameterCompleted += DoGetOrderCollectionByParameterCompleted;
            client.GetEmployeeCollectionCompleted += DoGetEmployeeCollectionCompleted;
            client.SearchOrderCompleted += DoSearchOrderCompleted;
            client.GetSingleOrderCompleted += DoGetSingleOrderCompleted;
            client.DeleteOrderCompleted += DoDeleteOrderCompleted;
            client.GetOrderCollectionCompleted += DoGetOrderCollectionCompleted;
        }

        public event EventHandler<CollectionFeedbackCompletedEventArgs<Order>> GetCollectionOrderCompleted;
        void DoGetOrderCollectionCompleted(object sender, CollectionFeedbackCompletedEventArgs<Order> e)
        {
            if (GetCollectionOrderCompleted != null)
            {
                GetCollectionOrderCompleted(sender,e);
            }
        }
        public int GetOrderCollectionAsync(bool isShowAll)
        {
            client.GetOrderCollectionAsync(isShowAll);
            return WebConstants.MagicNumer;
        }

        public event EventHandler<SingleFeedbackCompletedEventArgs<Order>> GetSingleOrderCompleted;
        
        void DoGetSingleOrderCompleted(object sender, SingleFeedbackCompletedEventArgs<Order> e)
        {
            if (GetSingleOrderCompleted != null)
            {
                GetSingleOrderCompleted(sender, e);
            }
        }
        public int GetSingleOrderAsync(int orderId)
        {
            client.GetSingleOrderAsync(orderId);
            return WebConstants.MagicNumer;
        }
        public event EventHandler<CollectionFeedbackCompletedEventArgs<Order>> SearchOrderCompleted;
         
        void DoSearchOrderCompleted(object sender, CollectionFeedbackCompletedEventArgs<Order> e)
        {
            if (SearchOrderCompleted != null)
            {
                SearchOrderCompleted(sender, e);
            }
        }
        public int SearchOrderAsync(OrderCriteria myOrder)
        {
            client.SearchOrderAsync(myOrder);
            return WebConstants.MagicNumer;
        }

        #region get employee collection

        public event EventHandler<CollectionFeedbackCompletedEventArgs<Employee>> GetEmployeeCollectionCompleted;
        void DoGetEmployeeCollectionCompleted(object sender, CollectionFeedbackCompletedEventArgs<Employee> e)
        {
            if (GetEmployeeCollectionCompleted != null)
            {
                GetEmployeeCollectionCompleted(sender, e);
            }
        }

        public int GetEmployeeCollectionAsync(bool isShowAll)
        {
            client.GetEmployeeCollectionAsync(isShowAll);
            return WebConstants.MagicNumer;
        }
        #endregion

        #region DoGetOrderCollectionByParameterCompleted

        public event EventHandler<CollectionFeedbackCompletedEventArgs<Order>> GetOrderCollectionByParameterCompleted;
        
        public int GetOrderCollectionByParameterAsync(bool? isMaterial)
        {
            client.GetOrderCollectionByParameterAsync(isMaterial);
            return WebConstants.MagicNumer;
        }

        void DoGetOrderCollectionByParameterCompleted(object sender, CollectionFeedbackCompletedEventArgs<Order> e)
        {
            if (GetOrderCollectionByParameterCompleted != null)
            {
                GetOrderCollectionByParameterCompleted(sender, e);
            }
        }

        #endregion

        #region DeleteOrder

        public event EventHandler<FeedbackCompletedEventArgs> DeleteOrderCompleted;

        public int DeleteOrderAsync(int objID)
        {
            client.DeleteOrderAsync(objID);
            return WebConstants.MagicNumer;
        }

        private void DoDeleteOrderCompleted(object sender, FeedbackCompletedEventArgs e)
        {
            if (DeleteOrderCompleted != null)
            {
                DeleteOrderCompleted(sender, e);
            }
        }

        #endregion

    }
}